package jdbc;

import javax.print.DocFlavor;
import java.sql.Connection;
import java.sql.Statement;
import java.util.Scanner;

public class RedDemo {
    public static void main(String[] args) {

        Scanner scanner=new Scanner(System.in);
        String username ;
        String nickname;
        Integer age;
        String password;
        username=scanner.nextLine();
        password=scanner.nextLine();
        nickname=scanner.nextLine();
        age=scanner.nextInt();
        try(Connection connection=DBUtil.getConnection();){

            Statement statement=connection.createStatement();
            String sql="INSERT INTO user(username,password,nickname,age) " +
                       "VALUES('"+username+"','"+password+"','"+nickname+"',"+age+")";
            System.out.println(sql);
            int num=statement.executeUpdate(sql);
            System.out.println(num>0?"注册成功":"注册失败");
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
